package com.xoa.service.event.impl;

import com.xoa.dao.event.TimeLineViewRoleMapper;
import com.xoa.model.event.TimeLineViewRole;
import com.xoa.service.event.TimeLineViewRoleService;
import com.xoa.util.ToJson;
import com.xoa.util.common.L;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by 张丽军 on 2017/9/1.
 */
@Service
public class TimeLineViewRoleServiceImpl implements TimeLineViewRoleService{

    @Resource
    TimeLineViewRoleMapper timeLineViewRoleMapper;
    @Override
    public ToJson<TimeLineViewRole> addTimeLineViewRole(HttpServletRequest request, TimeLineViewRole timeLineViewRole) {
        ToJson<TimeLineViewRole> toJson=new ToJson<>(1,"error");
        try{
            int a=timeLineViewRoleMapper.addTimeLineViewRole(timeLineViewRole);
            if(a>0){
                toJson.setMsg("ok");
                toJson.setFlag(0);
            }else {
                toJson.setMsg("新建失败");
                toJson.setFlag(1);
            }
        }catch (Exception e){
            e.printStackTrace();
            toJson.setMsg(e.getMessage());
            L.e("TimeLineViewRoleServiceImpl addTimeLineViewRole:"+e);
        }
        return toJson;
    }

    @Override
    public ToJson<TimeLineViewRole> updateTimeLineViewRole(HttpServletRequest request, TimeLineViewRole timeLineViewRole) {
        ToJson<TimeLineViewRole> toJson=new ToJson<>(1,"error");
        try{
            int b=timeLineViewRoleMapper.updateTimeLineViewRole(timeLineViewRole);
            if(b>0){
                toJson.setMsg("ok");
                toJson.setFlag(0);
            }else {
                toJson.setMsg("修改失败");
                toJson.setFlag(1);
            }
        }catch (Exception e){
            e.printStackTrace();
            toJson.setMsg(e.getMessage());
            L.e("TimeLineViewRoleServiceImpl updateTimeLineViewRole:"+e);
        }
        return toJson;
    }
}
